<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Questions | Edit question</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script type="text/javascript" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
    <link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link rel="shortcut icon" type="image/png" href="/static/img/favicon.png">
    <link rel="stylesheet" type="text/css" href="/static/main.css" />
  </head>
  <body>
    <nav class="navbar navbar-default navbar-static-top navbar-inverse">
      <div class="container">
        <div class="navbar-header">
          <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </button>
          <a class="navbar-brand" href="/">问答</a>
        </div>
        <div id="navbar" class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
          {{if not .questionUserID }}
          <li>
            <a href="/login?next=/chat"><i class="fa fa-commenting-o" aria-hidden="true"></i>&nbsp; 聊天</a>
          </li>
          {{else}}
          <li>
            <a href="/chat"><i class="fa fa-commenting-o" aria-hidden="true"></i>&nbsp; 聊天</a>
          </li>
          {{end}}
          <li>
            <a href="/categories"> 分类</a>
          </li>
          <li>
            <a href="/rank"> 用户榜</a>
          </li>
          <li>
            <a href="/"> 问题</a>
          </li>
          {{if .questionUserID }}
              {{if eq .questionUserID 1}}
              <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎 {{.user}} <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                      <li><a href="/admin"><i class="fa fa-user"></i> Admin</a></li>
                      <li><a href="/logout"><i class="fa fa-sign-out"></i> Logout</a></li>
                  </ul>
              </li>
              {{else}}
              <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">欢迎 {{.user}} <span class="caret"></span></a>
                  <ul class="dropdown-menu">
                      <li><a href="/profile/{{.questionUserID}}"><i class="fa fa-user"></i> Profile</a></li>
                      <li><a href="/logout"><i class="fa fa-sign-out"></i> Logout</a></li>
                  </ul>
              </li>
              {{end}}
          {{else}}
          <li>
            <a href="/login"> 登录</a>
          </li>
          <li>
            <a href="/signup"> 注册</a>
          </li>
          {{end}}
        </ul>
      </div>
    </nav>

    <div class="container">
      <div class="row">
        <div class="col-lg-8 col-lg-offset-2">
        <h3>Edit question</h3><br>
          <form action="/update/{{.question.Id}}" method="post">
            <div class="form-group">

              <input type="hidden" class="form-control" name="user" value="{{.questionUserID}}">
              <label>Title:</label>
              <input type="text" name="title" class="form-control" value="{{.question.Title}}" required>
              <span style="color:red">{{.a}}</span><br>
              <label>Content:</label>
              <textarea class="form-control" name="body" rows="8" class="form-control" required>{{.question.Body}}</textarea><br>
              <label>Tags:</label>
              <br>
              {{$questionId := .question.Id}}
              {{range .tags}}
              <a href="/tagedit/{{.Id}}?next=/edit/{{$questionId}}" class="btn btn-primary" title="Edit tag">{{.Name}}</a>
              {{end}}
              <br><br>
              <button type="submit" class="btn btn-success">
                <i class="fa fa-plus"></i> 提交
              </button>

            </div>
          </form>

        </div>
      </div>
    </div>

    </div>

  </body>
</html>
